package modelLayer;
import java.util.ArrayList;

public class ItemContainer{
    private ArrayList<Item> items;
    private static ItemContainer instance;
    
    private ItemContainer(){
        items = new ArrayList<>();
    }
    public static ItemContainer getInstance(){
        if(instance == null){
            instance = new ItemContainer();
        }
        return instance;
    }
    public void addNormalItem(Item newItem){
        items.add((NormalItem)newItem);
    }
    public void addSet(Item newItem){
        items.add((Set)newItem);
    }
    public ArrayList<Item> getAllItems(){
        return items;
    }
    
    public void removeNormalItem(int barcode){
       for(Item i: items){
           if(i instanceof NormalItem){
               if(((NormalItem)i).getBarcode()==barcode){
                   items.remove(i);
                }
            }
        }
    }
    
}